<template lang="jade">
div.rich_media#app(v-cloak)
	loading(:show.sync="showLoading", text="正在加载")
	div.homepage

		div.logo(v-show="showHeader")
			span.fr(v-if=" phone!=''  " )
				a(v-link="{ path: '/news/detail/2299' }", style="font-size:12px;border: 1px solid #ababab;color: #ababab;padding: 4px;border-radius:  4px;margin-right: 8px;") 风险提示
				a(v-link="{ path: '/user' }") {{phone}}
				a.sp |
				a(@click="loginOut()") 退出
			span.fr(v-else)
				a(v-link="{ path: '/news/detail/2299' }", style="font-size:12px;border: 1px solid #ababab;color: #ababab;padding: 4px;border-radius:  4px;margin-right: 8px;") 风险提示
				a(v-link="{ path: '/reg' }") 注册
				a.sp |
				a(v-link="{ path: '/login' }") 登录

	ul.menu(v-show="showTabbar")
		li(v-bind:class="{ 'on': getView('home') }", v-link="{ path: '/'}")
			div.img(v-show="getView('home')")
				img(src="./assets/images/public/tabber/home_on.png")
			div.img(v-show="!getView('home')")
				img(src="./assets/images/public/tabber/home.png")
			首页

		li(v-bind:class="{ 'on': getView('invest') }", v-link="{ path: '/invest/index?productype=current'}")
			div.img(v-show="getView('invest')")
				img(src="./assets/images/public/tabber/invest_on.png")
			div.img(v-show="!getView('invest')")
				img(src="./assets/images/public/tabber/invest.png")

			投标项目

		li(v-bind:class="{ 'on':  getView('news') }", v-link="{ path: '/news/index'}")
			div.img(v-show="getView('news')")
				img(src="./assets/images/public/tabber/news_on.png")
			div.img(v-show="!getView('news')")
				img(src="./assets/images/public/tabber/news.png")
			资讯频道

		li(v-bind:class="{ 'on':  getView('user') }", v-link="{ path: '/user'}")
			div.img(v-show="getView('user')")
				img(src="./assets/images/public/tabber/user_on.png")
			div.img(v-show="!getView('user')")
				img(src="./assets/images/public/tabber/user.png")
			个人中心
	router-view
</template>


<script>
import './assets/sass/_initialization.scss'
import {c_is_logined, Api_LoginOut} from './config/api'
import {Loading} from 'vux'
import store from './store/index'
import { mapGetters } from 'vuex'

export default{
	store,
	data(){
		return{

		}
	},



	components: {
		Loading
	},

	methods: {


		getView(key){
			var r_val = false
			if( this.$route.name == undefined && key=='home'){
				r_val = true;
			}else{
				if( this.$route.name == key  )
					r_val = true;
			}
			return r_val;
		},

	    loginOut: function (next) {
			this.phone = false;
	      this.$http({url: Api_LoginOut, method: 'GET'}).then(function (response) {
	        sessionStorage.removeItem("login");
	        //sessionStorage.removeItem("loan")
			//this.$route.router.go('/')
			window.location.reload();
	      }, function (response) {
	          console.log(response)
	      });
	    }

	},

	computed:{
		...mapGetters(['showLoading','phone']),

		showHeader(){
			var r_val = false, url = ['home','news']
			if( this.$route.name == undefined){
				r_val = true;
			}else{
				for(var a in url){
					if( this.$route.name == url[a]  )
						r_val = true;
				}
			}
			return r_val;

		},
	    showTabbar(){
			var r_val = false, url = ['home', 'invest', 'news', 'user']
			if( this.$route.name == undefined){
				r_val = true;
			}else{
				for(var a in url){
					if( this.$route.name == url[a]  )
						r_val = true;
				}
			}
			return r_val;
	    }
	}
}

</script>
